<?php/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: do_register.php 13111 2009-08-12 02:39:58Z liguode $
*/if(!defined('IN_UCHOME')) {
	exit('Access Denied');
}$op = $_GET['op'] ? trim($_GET['op']) : '';
if($_SGLOBAL['supe_uid']) {
	showmessage('do_success', 'space.php?do=home', 0);
}
//没有登录表单
$_SGLOBAL['nologinform'] = 1;
$jumpurl = 'index.php';
if(empty($op)) {	if($_SCONFIG['closeregister']) {
		if($_SCONFIG['closeinvite']) {
			showmessage('not_open_registration');
		} elseif(empty($invitearr)) {
			showmessage('not_open_registration_invite');
		}
	}	
	//是否关闭站点
	checkclose();
	if(submitcheck('registersubmit')) {		if($_POST['password'] != $_POST['password2']) {
			showmessage('password_inconsistency');
		}
		if(!$_POST['password'] || $_POST['password'] != addslashes($_POST['password'])) {
			showmessage('profile_passwd_illegal');
		}
		$username =  addslashes(trim(stripslashes($_POST['username'])));		$password = addslashes(trim(stripslashes($_POST['password'])));		$mobile = addslashes(trim(stripslashes($_POST['mobile'])));		//$email = 'u@sjl.com';		// 记录手机		if(!empty($mobile)&&!preg_match("/^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$/",$mobile))			showmessage('请填写正确的手机号码。','do.php?ac=register');		
		//检查IP		$onlineip = getonlineip();		if($_SCONFIG['regipdate']) {
			$query = $_SGLOBAL['db']->query("SELECT regtime FROM ".tname('member')." WHERE regip='$onlineip' ORDER BY regtime DESC LIMIT 1");
			if($value = $_SGLOBAL['db']->fetch_array($query)) {
				if($_SGLOBAL['timestamp'] - $value['regtime'] < $_SCONFIG['regipdate']*3600) {
					showmessage('regip_has_been_registered', '', 1, array($_SCONFIG['regipdate']));
				}
			}
		}		include_once S_ROOT.'./source/action/act_user.php';		$user = new act_user();
	
		if(!act_user::check_username($username))		{			showmessage('用户名不合要求','do.php?ac=register');die;		}		if(act_user::check_usernamecensor($username))		{			showmessage('不容许注册该用户名','do.php?ac=register');die;		}		if($user->check_usernameexists($username))		{			showmessage('user_name_already_exists','do.php?ac=register');die;		}		
		$newuid = $user->register_user($username, &$password, $mobile);		if($newuid == 0) {	
				showmessage('register_error','do.php?ac=register');	
		} else {	
			$setarr = array(	
				'uid' => $newuid,	
				'username' => $username,	
				'password' => $password	
			);	
			//在线session			include_once(S_ROOT.'./source/function_space.php');			insertsession($setarr);	//			//变更记录	//
	//			if($_SCONFIG['my_status']) inserttable('userlog', array('uid'=>$newuid, 'action'=>'add', 'dateline'=>$_SGLOBAL['timestamp']), 0, true);	//
//			if(!$passport = getpassport($username, $password)) {//	
//				showmessage('login_failure_please_re_login', 'do.php?ac=login');//	
//			}				ssetcookie('auth', authcode("$setarr[password]\t$setarr[uid]", 'ENCODE'), 60*60*24*7);		
			$uids=$passport['uid'];			
			$sid=$passport['passport'];			
			showmessage('registered', $jumpurl);	
		}	}
//	$register_rule = data_get('registerrule');	include template('do_register');//} elseif($op == "checkusername") {//
//	$username = trim($_GET['username']);//
//	if(empty($username)) {//
//		showmessage('user_name_is_not_legitimate');//
//	}//
////
//	if($ucresult == -1) {//
//		showmessage('user_name_is_not_legitimate');//
//	} elseif($ucresult == -2) {//
//		showmessage('include_not_registered_words');//
//	} elseif($ucresult == -3) {//
//		showmessage('user_name_already_exists');//
//	} else {//
//		showmessage('succeed');//
//	}
} elseif($op == "checkseccode") {	include_once(S_ROOT.'./source/function_cp.php');	if(ckseccode(trim($_GET['seccode']))) {		showmessage('succeed');	} else {		showmessage('incorrect_code');	}
}

?>